<?php
require('../../class/connect.php'); //引入数据库配置文件和公共函数文件
require('../../class/db_sql.php'); //引入数据库操作文件

$product = $_POST["product"]; //产品线
$seq = $_POST["seq"]; //序列
$type = $_POST["type"]; //型号
$softtype = $_POST["softtype"]; // 软件类型（文档 驱动）
$os = $_POST["os"]; //操作系统
$level=$_POST["level"];
$classid=$_POST["classid"];

$link = db_connect(); //连接MYSQL
$empire = new mysqlquery(); //声明数据库操作类
$editor = 1; //声明目录层次
$response = "";

if ($level==1) {
    $response="";
    $sql = $empire->query("select classid, classname, bclassid, islast, classpath, classurl,tbname from {$dbtbpre}enewsclass where  bclassid=$product and wburl='' order by myorder,classid"); //
    while ($r = $empire->fetch($sql)) //循环获取查询记录
    {
        $response = $response . "<option class='temp' value=\"$r[classid]\">$r[classname]</option>";
    }
    echo $response;
}

if ($level ==2) {
    $tbname="product";
    $classsql = $empire->query("select t.tbname from {$dbtbpre}enewsclass c,{$dbtbpre}enewstable t where c.tid=t.tid and  c.classid=$seq "); //
    while($r1=$empire->fetch($classsql)){
        $tbname=$r1[tbname];
    }

    $response="";
    $sql = $empire->query("select id, title from {$dbtbpre}ecms_$tbname where classid=$seq  order by id"); //
    while ($r = $empire->fetch($sql)) //循环获取查询记录
    {
        $response = $response . "<option class='temp' value=\"$r[id]\">$r[title]</option>";
    }
    echo $response;
}

if ($level ==3) {
    $response="";
    $sql = $empire->query("select  type from {$dbtbpre}ecms_document where p_id=$type  and classid=\"$classid\" group by type"); //
    while ($r = $empire->fetch($sql)) //循环获取查询记录
    {
        $response = $response . "<option class='temp' value=\"$r[type]\">$r[type]</option>";
    }
    echo $response;
}

if ($level==4) {
    $response="";
    $sql = $empire->query("select  os from {$dbtbpre}ecms_document where p_id=$type  and  type=\"$softtype\" and classid=\"$classid\"   group by os"); //
    while ($r = $empire->fetch($sql)) //循环获取查询记录
    {
        $response = $response . "<option class='temp' value=\"$r[os]\">$r[os]</option>";
    }
    echo $response;
}

if ($level==5) {
    $response = " <tbody><tr><th>日期</th><th>说明</th><th>版本</th><th>操作系统</th><th>下载</th></tr>";
    $sql = $empire->query("select document_date, id, type,note, os,edition,file,file_size from {$dbtbpre}ecms_document where os=\"$os\" and type=\"$softtype\" and classid=\"$classid\" and p_id=\"$type\"    "); //
    while ($r = $empire->fetch($sql)) //循环获取查询记录
    {
        $response = $response . "<tr><td>$r[document_date]</td><td>$r[note]</td><td>$r[edition]</td><td>$r[os]</td><td>";
        if($r[file]==null){
            $response = $response."下载";
        }else{
            $filesize=$r[file_size]/(1024*1024);
            $filesize=round($filesize,3);
            $filesize=$filesize."MB";
            $response = $response."<a href=\"$r[file]\">$filesize</a>";

        }
        $response = $response . "</td></tr></tbody>";
    }
    echo $response;
}